<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>python_daemon_tools.runner &mdash; python-daemon-tools v0.0.1 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '../',
          VERSION:     '0.0.1',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="contents" title="Global table of contents" href="../contents.html" />
    <link rel="index" title="Global index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="top" title="python-daemon-tools v0.0.1 documentation" href="../index.html" />
    <link rel="next" title="python_daemon_tools.helper" href="helper.html" />
    <link rel="prev" title="Welcome to Python-Daemon-Tools documentation!" href="../index.html" />
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="helper.html" title="python_daemon_tools.helper"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../index.html" title="Welcome to Python-Daemon-Tools documentation!"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">python-daemon-tools v0.0.1 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="module-python_daemon_tools.runner">
<h1><tt class="xref docutils literal"><span class="pre">python_daemon_tools.runner</span></tt><a class="headerlink" href="#module-python_daemon_tools.runner" title="Permalink to this headline">¶</a></h1>
<p>This module borrows heavily from <a class="reference external" href="http://pypi.python.org/pypi/python-daemon/">python_daemon</a> available at Pypi</p>
<p>&#64;author: Jean-Lou Dupont</p>
<div class="section" id="classes">
<h2>Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="python_daemon_tools.runner.DaemonRunner">
<!--[python_daemon_tools.runner.DaemonRunner]-->class <tt class="descclassname">python_daemon_tools.runner.</tt><tt class="descname">DaemonRunner</tt><big>(</big><em>app</em>, <em>messages=None</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunner" title="Permalink to this definition">¶</a></dt>
<dd><p>Controller class for a callable running in a separate background process</p>
<p>The principal methods are:</p>
<ul class="simple">
<li><a title="python_daemon_tools.runner.DaemonRunner.cmd_start" class="reference internal" href="#python_daemon_tools.runner.DaemonRunner.cmd_start"><tt class="xref docutils literal"><span class="pre">cmd_start()</span></tt></a></li>
<li><a title="python_daemon_tools.runner.DaemonRunner.cmd_stop" class="reference internal" href="#python_daemon_tools.runner.DaemonRunner.cmd_stop"><tt class="xref docutils literal"><span class="pre">cmd_stop()</span></tt></a></li>
</ul>
<p>The <tt class="docutils literal"><span class="pre">PID</span> <span class="pre">lock</span> <span class="pre">file</span></tt> is derived from <tt class="docutils literal"><span class="pre">app.name</span></tt> in the following way</p>
<pre>${app.pid_directory}/${app.name}.pid</pre>
<p>and by default is located in the <tt class="docutils literal"><span class="pre">/var/run</span></tt> directory; this directory
can be customized through the <tt class="docutils literal"><span class="pre">app.pid_directory</span></tt> attribute.</p>
<p>The exceptions generated by this class contain <cite>pseudo-messages</cite> which are
really meant as <cite>index</cite> to human readable messages. This way, customization
is easier to handle.</p>
</dd></dl>

<dl class="method">
<dt id="python_daemon_tools.runner.DaemonRunner.__init__">
<!--[python_daemon_tools.runner.DaemonRunner.__init__]--><tt class="descclassname">DaemonRunner.</tt><tt class="descname">__init__</tt><big>(</big><em>app</em>, <em>messages=None</em>, <em>logger=None</em><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunner.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>The parameter <tt class="docutils literal"><span class="pre">app</span></tt> must be a callable with, as minimum, the following attributes:</p>
<ul class="simple">
<li><em>name</em></li>
<li><em>run()</em> method</li>
</ul>
<p>Optional attributes are:</p>
<ul class="simple">
<li><em>before_start()</em> method</li>
<li><em>before_run()</em> method</li>
</ul>
<p>The parameter <em>messages</em> must behaved like a dictionary. The list of messages for
which the dictionary should have an entry is available through the class constant 
<tt class="xref docutils literal"><span class="pre">messages_logger</span></tt> for the logging activities and the class constant 
<tt class="xref docutils literal"><span class="pre">messages_exception</span></tt> for the exceptions.</p>
<p>The parameter <em>logger</em> is meant to receive a compatible callable to the
<tt class="docutils literal"><span class="pre">logging</span></tt> module. This parameter defaults to <tt class="docutils literal"><span class="pre">timed</span> <span class="pre">rotating</span></tt> file of the form</p>
<pre>/var/log/${app.name}.log</pre>
<p>Note that this logger is only active when the daemon is started: prior to this,
only exceptions are raised for conferring error conditions.</p>
</dd></dl>

<dl class="method">
<dt id="python_daemon_tools.runner.DaemonRunner.cmd_start">
<!--[python_daemon_tools.runner.DaemonRunner.cmd_start]--><tt class="descclassname">DaemonRunner.</tt><tt class="descname">cmd_start</tt><big>(</big><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunner.cmd_start" title="Permalink to this definition">¶</a></dt>
<dd><p>Starts the daemon for <tt class="docutils literal"><span class="pre">app</span></tt></p>
<p>The method <tt class="docutils literal"><span class="pre">app.before_start()</span></tt> is called prior to actually daemonizing;
the method can abort the process by raising ...</p>
<p>The method <tt class="docutils literal"><span class="pre">app.before_start()</span></tt> need not to exist (a validity check is performed).</p>
</dd></dl>

<dl class="method">
<dt id="python_daemon_tools.runner.DaemonRunner.cmd_stop">
<!--[python_daemon_tools.runner.DaemonRunner.cmd_stop]--><tt class="descclassname">DaemonRunner.</tt><tt class="descname">cmd_stop</tt><big>(</big><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunner.cmd_stop" title="Permalink to this definition">¶</a></dt>
<dd>Stops the daemon for (the currently running) <tt class="docutils literal"><span class="pre">app</span></tt> but not before calling <tt class="docutils literal"><span class="pre">app.stop</span></tt></dd></dl>

<dl class="method">
<dt id="python_daemon_tools.runner.DaemonRunner.cmd_restart">
<!--[python_daemon_tools.runner.DaemonRunner.cmd_restart]--><tt class="descclassname">DaemonRunner.</tt><tt class="descname">cmd_restart</tt><big>(</big><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunner.cmd_restart" title="Permalink to this definition">¶</a></dt>
<dd>Restarts the daemon for (the currently running) <tt class="docutils literal"><span class="pre">app</span></tt></dd></dl>

<dl class="class">
<dt id="python_daemon_tools.runner.DaemonRunnerException">
<!--[python_daemon_tools.runner.DaemonRunnerException]-->class <tt class="descclassname">python_daemon_tools.runner.</tt><tt class="descname">DaemonRunnerException</tt><big>(</big><em>message</em>, <em>params=None</em><big>)</big><a class="headerlink" href="#python_daemon_tools.runner.DaemonRunnerException" title="Permalink to this definition">¶</a></dt>
<dd><p>DaemonRunner Exception base class</p>
<p>Allows for easier customization of error messages.</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>Table Of Contents</h3>
            <ul>
<li><a class="reference external" href=""><tt class="docutils literal"><span class="pre">python_daemon_tools.runner</span></tt></a><ul>
<li><a class="reference external" href="#classes">Classes</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="../index.html" title="previous chapter">Welcome to Python-Daemon-Tools documentation!</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="helper.html" title="next chapter"><tt class="docutils literal"><span class="pre">python_daemon_tools.helper</span></tt></a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/modules/runner.txt">Show Source</a></li>
            </ul>
            <h3>Quick search</h3>
            <form class="search" action="../search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="helper.html" title="python_daemon_tools.helper"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../index.html" title="Welcome to Python-Daemon-Tools documentation!"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">python-daemon-tools v0.0.1 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2009, Jean-Lou Dupont.
      Last updated on Mar 30, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>